<?php

require '../conn.php';

require 'config.php';

require '../inc/function.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="../css/admin.css" type="text/css" />

<script src="inc/function.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>

<?php
 
$back_url='pro.php';

 
$ids=$_GET['ids'];

$n_order=$_POST['n_order'];

$n_image=$_POST['n_image'];

switch($act){

case 'add';

	mysql_query("insert into ".$language."_pro_image(n_class,n_order,n_image) values($id,$n_order,'$n_image')",$conn);

	Msg('','PageUrl');

	break;

case 'modify';

	$image_original=RsField('select n_image from '.$language.'_pro_image where n_id='.$ids);

	mysql_query("update ".$language."_pro_image set n_order=$n_order,n_image='$n_image' where n_id=$ids",$conn);

	if ($n_image!=$image_original) DeleteFile('../'.$image_original);

	Msg('','PageUrl');

	break;

case 'delete';

	$image_original=RsField('select n_image from '.$language.'_pro_image where n_id='.$ids);

	mysql_query("delete from ".$language."_pro_image where n_id=$ids",$conn);

	DeleteFile('../'.$image_original);

	Msg('','Referer');

	break;

}

?>

<div id="container">

	<?php

	echo '<p style="margin-bottom:5px;"><strong>作品名称：</strong>'.RsField('select n_title from '.$language.'_pro where n_id='.$id).'&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$back_url.'?'.$urls.'">返回上页</a></p>';

	if ($_GET['meters']==1){

	$query=mysql_query('select * from '.$language.'_pro_image where n_id='.$ids,$conn);

	$row=mysql_fetch_array($query);

	?>

    <div class="edit">

      <h1>作品图片<a href="javascript:location.reload();">刷新</a></h1>

      <form name="form1" method="post" action="?act=modify&<?php echo $urls.'&id='.$id.'&ids='.$ids ?>" onsubmit="return CheckProductsImage(this);">

        <table width="100%" border="0" cellpadding="0" cellspacing="0">

          <tr>

            <td class="edit_title">作品图片：</td>

            <td><input name="n_image" type="text" class="inputtext" id="n_image" value="<?php echo $row['n_image'] ?>" size="50" readonly="readonly" />&nbsp;(图片800x8000)<iframe src="../upload_fy.php?file_type=0&file_id=n_image" frameborder="0" allowtransparency="true" scrolling="no" width="100%" height="25"></iframe></td>

          </tr>

          <tr>

            <td class="edit_title">图片排序：</td>

            <td><input name="n_order" type="text" class="inputtext" value="<?php echo $row['n_order'] ?>" size="10" maxlength="10" /></td>

          </tr>

          <tr>

            <td height="30">&nbsp;</td>

			<td><input name="button" type="submit" value=" 修改 " class="button" />&nbsp;<input name="button" type="button" value=" 返回 " class="button" onclick="history.back();" /></td>

          </tr>

        </table>

      </form>

    </div>

	<?php

	}

	else {

	?>

	<div class="view">

		<h1>作品图片<a href="javascript:location.reload();">刷新</a></h1>

	    <table width="100%" border="0" cellpadding="0" cellspacing="0">

        	<tr class="v_title">

            	<td width="10%">序号</td>

            	<td width="60%">图片预览</td>

				<td width="15%">图片排序</td>

				<td width="15%">操作</td>

        	</tr>

			<?php

			$col=1;

			$query=mysql_query('select * from '.$language.'_pro_image where n_class='.$id.' order by n_order,n_id');

			if (mysql_num_rows($query)>0){

				$str='';

				while($row=mysql_fetch_array($query)){

					$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';

					$str.='<td>'.$col.'</td>';

					$str.='<td style="padding:5px; line-height:normal; font-size:0px;"><a href="../'.$row['n_image'].'" target="_blank"><img src="../'.$row['n_image'].'" height="40" /></a></td>';

					$str.='<td><div class="inputorder" id="inputorder_'.$row['n_id'].'" contenteditable="true" onblur="Ordern(\'pro_image\','.$row['n_id'].')">'.$row['n_order'].'</div></td>';

					$str.='<td><a href="pro_images.php?'.$urls.'&meters=1&id='.$id.'&ids='.$row['n_id'].'">修改</a> | <a href="?act=delete&ids='.$row['n_id'].'" onclick="return ConfirmDel();">删除</a></td>';

					$str.='</tr>';

					$col++;

				}

				echo $str;

			}

			?>

		</table>

	</div><br />

    <div class="edit">

      <h1>&nbsp;</h1>

      <form name="form1" method="post" action="?act=add&<?php echo $urls.'&id='.$id.'&ids='.$ids ?>" onsubmit="return CheckProductsImage(this);">

        <table width="100%" border="0" cellpadding="0" cellspacing="0">

          <tr>

            <td class="edit_title">作品图片：</td>

            <td><input name="n_image" id="n_image" type="text" class="inputtext" size="50"   />&nbsp;(图片800x8000)<iframe src="../upload_fy.php?file_type=0&file_id=n_image" frameborder="0" allowtransparency="true" scrolling="no" width="100%" height="25"></iframe></td>

          </tr>

          <tr>

            <td class="edit_title">图片排序：</td>

            <td><input name="n_order" type="text" class="inputtext" value="<?php echo $col ?>" size="10" maxlength="10" /></td>

          </tr>

          <tr>

            <td height="30">&nbsp;</td>

			<td><input name="button" type="submit" value=" 添加 " class="button" /></td>

          </tr>

        </table>

      </form>

    </div>

    <?php } ?>

</div>

</body>

</html>